//************************************************************************
/// <copyrigth>2024-2025 Corporation.All Rights Reserved</copyrigth>
/// <author>tangyingzhong</author>
/// <contact>tangyz114987@outlook.com</contact>
/// <version>v1.0.0</version>
/// <describe>
/// Cross-Platform event notification which can helpe different modules communication
///</describe>
/// <date>2024/4/28</date>
///***********************************************************************
#ifndef IBASEEVENT_H
#define IBASEEVENT_H

#include <functional>
#include "ModuleLoader/ModuleConfig.h"

namespace SystemTool
{
    struct EventArgs
    {
        // Sender
        void* pSender = nullptr;

        // Event Id
        int iEventId = 0;

        // Args
        void* pArgs = nullptr;

        // Reserved
        void *pReserved = nullptr;
    };
    
    class CLASS_ITEM IBaseEvent
    {
    public:
        // Destruct the obj
        virtual ~IBaseEvent(){    }

        // Register the event
        virtual void Register(int iEventId, std::function<void(EventArgs &)> fEventHandlerFunc) = 0;

        // Unregister the event
        virtual void UnRegister(int iEventId, std::function<void(EventArgs &)> fEventHandlerFunc) = 0;

        // Notify the target
        virtual void Notify(EventArgs &Args) = 0;

        // Asyn notify the event
        virtual void AsynNotify(EventArgs &Args, std::function<void(EventArgs &)> fResFunc = nullptr, long lTimeout_Ms = 60000) = 0;
    };
}

#endif // IBASEEVENT_H
